#########################################################################
##
## This file is part of the SAMRAI distribution.  For full copyright 
## information, see COPYRIGHT and LICENSE. 
##
## Copyright:     (c) 1997-2019 Lawrence Livermore National Security, LLC
## Description:   makefile for Euler gas dynamics sample application 
##
#########################################################################

SAMRAI	      = @top_srcdir@
SRCDIR        = @srcdir@
SUBDIR        = source/test/performance/Euler
VPATH         = @srcdir@
TESTTOOLS     = ../../testtools
OBJECT        = ../../../..
REPORT        = $(OBJECT)/report.xml

default:	main

include $(OBJECT)/config/Makefile.config

SUBDIRS = fortran

CPPFLAGS_EXTRA=

NUM_TESTS = 0

TEST_NPROCS = @TEST_NPROCS@
PERF_NPROCS = 16,32,64

CXX_OBJS      = main.o Euler.o 
F_OBJS      = \
		fortran/avgint2d.o fortran/flaten1d2d.o fortran/flux2d.o \
		fortran/grad2d.o fortran/init2d.o fortran/stable2d.o \
		fortran/stufprobc.o fortran/trace2d.o fortran/trace1d2d.o \
		fortran/avgint3d.o fortran/flaten1d3d.o fortran/flux3d.o \
		fortran/grad3d.o fortran/init3d.o fortran/stable3d.o \
		fortran/trace3d.o fortran/trace1d3d.o fortran/fluxcorner3d.o

main:	$(CXX_OBJS) $(F_OBJS) $(LIBSAMRAIDEPEND)
	for DIR in $(SUBDIRS); do if test -d $$DIR; then (cd $$DIR && $(MAKE) $@) ; fi || exit 1; done
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(CXX_OBJS) $(F_OBJS)     \
	$(LIBSAMRAI) $(LDLIBS) -o main

# Prevents "No rule to make target" error.  Built in the rule for main.
fortran/avgint2d.o:

fortran/flaten1d2d.o:

fortran/flux2d.o:

fortran/grad2d.o:

fortran/init2d.o:

fortran/stable2d.o:

fortran/stufprobc.o:

fortran/trace2d.o:

fortran/trace1d2d.o:

fortran/avgint3d.o:

fortran/flaten1d3d.o:

fortran/flux3d.o:

fortran/grad3d.o:

fortran/init3d.o:

fortran/stable3d.o:

fortran/trace3d.o:

fortran/trace1d3d.o:

fortran/fluxcorner3d.o:

testlib:
	cd $(TESTLIBDIR) && $(MAKE) library

check:

checkcompile:	main

checktest:
	$(RM) makecheck.logfile
	$(MAKE) check 2>&1 | $(TEE) makecheck.logfile
	$(OBJECT)/source/test/testtools/testcount.sh $(TEST_NPROCS) $(NUM_TESTS) 0 makecheck.logfile
	$(RM) makecheck.logfile

examples:

perf:	main
	@for i in performance_inputs/mEuler/*.input ; do	\
	  $(OBJECT)/config/serpa-run $(PERF_NPROCS) \
		./main $${i};	\
	done

everything:
	$(MAKE) checkcompile || exit 1
	$(MAKE) checktest
	$(MAKE) examples
	$(MAKE) perf

checkclean:
	$(CLEAN_COMMON_CHECK_FILES)
	$(RM) *.timing*

clean: checkclean
	$(CLEAN_COMMON_TEST_FILES)
	$(RM) main
	for DIR in $(SUBDIRS); do if test -d $$DIR; then (cd $$DIR && $(MAKE) $@) ; fi || exit 1; done

redo:
	$(RM) main core *.ii *.int.c
	$(RM) ti_files ii_files

include $(SRCDIR)/Makefile.depend
